//
//  BCUserSafeCenterRequest.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/12/6.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "BCUserSafeCenterRequest.h"

@implementation BCUserSafeCenterRequest
- (HttpRequestMethod)requestMethod {
    return GET;
}
- (NSString *)relativelyUrl {
    return V1_Flow_Wallet_Safety;
}

- (BOOL)success:(NSURLSessionDataTask *)task data:(id)obj {
    BOOL success = [super success:task data:obj];
    if (success) {
        BCUserSafeCenterResponse *resp = [BCUserSafeCenterResponse yy_modelWithJSON:obj];
        if (self.requestSuccessed) {
            self.requestSuccessed(resp, nil);
        }
    }
    return success;
}






/**
 发起一次请求
 */
+ (void)requestData:(void(^)(BCUserSafeCenterResponse  *,NSError *))complete {
    BCUserSafeCenterRequest *requst = [BCUserSafeCenterRequest new];
    [requst didRequestSuccessed:^(id result, id page) {
        //更新
        BCUserSafeCenterResponse *response = result;
        [BCUserManager sharedUser].safeCenterData = response.data;
        if (complete) {
            complete(result,nil);
        }
    }];
    [requst didRequestFailed:^(NSError *error) {
        if (complete) {
            complete(nil,error);
        }
    }];
    [requst requestServer];
}

@end
